package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import com.atguigu.springcloud.service.PaymentFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 孙志鹏
 * @createDate 2022/4/4 13:32
 */
@RestController
@RequestMapping("/payment/consumer")
public class PaymentFeignController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    /**
     * 根据Id进行获取Payment
     * @param id id
     * @return
     */
    @GetMapping("/{id}")
    public CommonResult<Payment> getElementById(@PathVariable("id") Long id) {
        return paymentFeignService.getPaymentById(id);
    }

    /**
     * 超时测试
     * @return
     */
    @GetMapping(value = "/feign/timeout")
    public String paymentFeignTimeOut() {
        return paymentFeignService.paymentFeignTimeOut();
    }
}
